<?php defined('SYSPATH') OR die('No direct access allowed.');

class Website_Controller extends Template_Controller {

	public function __construct()
	{
		parent::__construct();

		$t = $this->template;

		$t->title 		= 'jBnotes.info - incidental notes';
		$t->description	= 'Incidental notes. ';
		$t->keywords	= array('Kohana', 'PHP', 'fabryc');
		$t->copyright	= '&copy; 2009 J.B.Early';
		$t->sheets		= array('plain', 'lightcolors');
		$t->menu		= array(array('Home'=>'home', 'Contact'=>'contact'));
		$t->content		= '';

		$this->fabryc = new Fabryc(array('root' => 'pages/','prefix'=>'pages/'));
	}

	public function index()
	{
		$this->_make(func_get_args());
		$this->template->content = $this->_content(func_get_args());
	}

	protected function _make($args)
	{
		if($fmenu = $this->fabryc->get_menu($args)) {
			$this->template->menu = array_merge($this->template->menu,$fmenu);
		}
	}

	protected function _filepath($args)
	{
		$path = $this->fabryc->get_filepath($args);
		return $path;
	}

	protected function _content($args)
	{
		return '';
	}

	protected function _fabryc_content($fabryc_text)
	{
		list($content,$kws,$desc,$errors) = $this->fabryc->process_file($path);

		$this->_add_description($desc);
		$this->_add_keywords($kws);

		return $content;
			}

	protected function _add_description($desc)
	{
		$this->template->description .= "$desc ";
	}

	protected function _add_keywords($kws)
	{
		$this->template->keywords = array_merge($this->template->keywords,util::asArray($kws));
	}
}

// eof